// 01字典树
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int son[N * 31][2]; // 存储 Trie 树的 “边”（节点间的连接）
int idx;       // 分配节点的唯一 ID
void insert_trie(int x)
{
    int p = 0;
    for (int i = 30; i >= 0; i--)
    {
        int tmp = (x >> i) & 1;
        if (son[p][tmp] == 0)
            son[p][tmp] = ++idx;
        p = son[p][tmp];
    }
}
int count_num_trie(int x)
{
    int p = 0;
    int res = 0;
    for (int i = 30; i >= 0; i--)
    {
        int tmp = (x >> i) & 1;
        if (son[p][!tmp])
        {
            p = son[p][!tmp];
            res = res * 2 + 1;
        }
        else
        {
            p = son[p][tmp];
            res = res * 2;
        }
    }
    return res;
}
int main()
{
    int n;
    char op;
    cin >> n;
    vector<int> a(n + 10);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        insert_trie(a[i]);
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        res = max(res, count_num_trie(a[i]));
    }
    cout << res << endl;
}